package logic

import (
	"context"
	"medi-reserve/model"

	"medi-reserve/medirpc/internal/svc"
	"medi-reserve/medirpc/medirpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type AddReserveLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewAddReserveLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddReserveLogic {
	return &AddReserveLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *AddReserveLogic) AddReserve(in *medirpc.AddReserveRequest) (*medirpc.AddReserveResponse, error) {
	// todo: add your logic here and delete this line
	reserve := &model.Reserve{
		//Model:       gorm.Model{ID:},
		Name:        in.Name,
		ReserveCode: int(in.ReserveCode),
		WxName:      in.WxName,
		Tel:         int(in.Tel),
	}
	reserve.AddReserve(model.DB)
	return &medirpc.AddReserveResponse{
		ReserveId: int64(reserve.ID),
	}, nil
}
